Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Ex command :py= evaluate and print python expression #548

Merged
merged 3 commits into from
Nov 13, 2023

Conversation

wookayin
Copy link
Member

@wookayin wookayin commented Oct 18, 2023

The Ex command :py, :python, :py3, etc. can evaluate the line as an expression rather than a statement if the line starts with =, just like :lua=.

:py= <expr> is equivalent as :py print(<expr>).

:py3= sys.version_info[:3]
:python3 =pynvim.__version__

TODO

  • How to document into /doc/if_pyth.txt (neovim core)? The feature would require pynvim 0.5.0 (or devel). It would make sense to submit a PR to neovim core only after a stable release of pynvim that contains this patch is released.

Developer note:

should be merged (or rebased) after #547 to avoid conflicts (Merged)

The Ex command `:py`, `:python`, :`py3`, etc. can evaluate the line
as an expression rather than a statement if the line starts with `=`,
just like `:lua=`.

`:py= <expr>` is equivalent as `:py print(<expr>)`.

```vim
:py3= sys.version_info[:3]
:python3 =pynvim.__version__
```
@wookayin wookayin marked this pull request as ready for review November 13, 2023 19:50
@justinmk
Copy link
Member

How to document into /doc/if_pyth.txt (neovim core)? The feature would require pynvim 0.5.0 (or devel).

Better to get it in there asap. One more motivation for doing a pynvim release :)

@justinmk justinmk merged commit 1696737 into neovim:master Nov 13, 2023
19 checks passed
@wookayin wookayin deleted the feat-py-expr branch November 13, 2023 22:28
@wookayin
Copy link
Member Author

wookayin commented Nov 28, 2023

Hmm now I think we may want to use repr(...) to print. For example, python3= "foo" might print 'foo' instead of foo only. Will think about it in any subsequent PRs....

Need to make the behavior consistent with neovim/neovim#25379

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants